/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PanelNewton.java
 *
 *
 */
package interfaz.FuncionPanels.ecuaciones;

import funcion.ManejadorFuncion;
import interfaz.NuMethodApp;
import interfaz.NuMethodConstants;
import java.awt.Color;
import java.io.IOException;
import java.util.ArrayList;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import metodos.Biseccion;
import metodos.Newton;
import metodos.Secante;
//import metodos.ManejadorMetodo;

/**
 *
 * @author The NuMethod Team
 */
public class PanelSecante extends javax.swing.JPanel {

    private String f; ///El String que representara la funcion f(X) a utilizar
    //Variables de la aplicacion
    /**
     * Arreglo de cabeceras de la tabla Biseccion
     */
    String[] names = {"N", "Xn", "Yn", "Error"};
    private static ImageIcon errorIcon;
    private static ImageIcon okIcon;
    private static ImageIcon halfSuccessIcon;

    /** Creates a new form PanelNewton*/
    public PanelSecante() {
        initComponents();
        initComponents2();


    }

    /**
     * Metodo de utilidad para terminar manualmente la inicializacion de la Interfaz
     */
    private void initComponents2() {
        errorIcon = new ImageIcon(getClass().getResource("/recursos/Icons16/agt_action_fail.png"));
        okIcon = new ImageIcon(getClass().getResource("/recursos/Icons16/agt_action_success.png"));
        halfSuccessIcon = new ImageIcon(getClass().getResource("/recursos/Icons16/admin_icon.png"));


        // Construir una tabla de 2 * 4 para almacenar los datos
        Object[][] data = new Double[2][4];
        DefaultTableModel tm = new DefaultTableModel(data, names);
        TableSecante.setModel(tm);

        //Metodo que establece las funciones desde el panel principal
        updateFunctions();
    }

    /**
     * Este metodo actualiza este panel con las ultimas funciones que han sido
     * <br> colocadas en el sistema
     *
     * <p>
     * Para el caso de Metodo de la secante, esta funcion establece la funcion
     * <br> <b>f(x)</b>
     */
    public void updateFunctions() {
        f = NuMethodApp.getF();
        LabelFText.setText(f);

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        SPanelProceso = new javax.swing.JScrollPane();
        TableSecante = new org.jdesktop.swingx.JXTable();
        PanelEntrada = new javax.swing.JPanel();
        BotonEjecutar = new javax.swing.JButton();
        LabelInStatus = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        FieldInicial = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        FieldTol = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        FieldIteraciones = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        FieldInicial2 = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        PanelSalida = new javax.swing.JPanel();
        LabelSalida = new javax.swing.JLabel();
        LabelSalida2 = new javax.swing.JLabel();
        PanelEstado = new javax.swing.JPanel();
        LabelF = new javax.swing.JLabel();
        LabelFText = new javax.swing.JLabel();
        LabelFPrimaText = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();

        setForeground(new java.awt.Color(255, 0, 255));

        SPanelProceso.setBorder(javax.swing.BorderFactory.createTitledBorder("Proceso"));
        SPanelProceso.setToolTipText("Proceso de salida");

        TableSecante.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        SPanelProceso.setViewportView(TableSecante);

        PanelEntrada.setBorder(javax.swing.BorderFactory.createTitledBorder("Entrada"));

        BotonEjecutar.setText("Ejecutar");
        BotonEjecutar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotonEjecutarActionPerformed(evt);
            }
        });

        jPanel2.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        FieldInicial.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                FieldInicialActionPerformed(evt);
            }
        });

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/Icons16/kodo.png"))); // NOI18N
        jLabel2.setText("Valor Inicial 1");
        jLabel2.setToolTipText("Valor de inicio del metodo");

        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/Icons16/agt_update_critical.png"))); // NOI18N
        jLabel3.setText("Tolerancia");
        jLabel3.setToolTipText("Valor maximo de error que se espera devuelva el metodo");

        jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/Icons16/idea.png"))); // NOI18N
        jLabel4.setText("# de iteraciones");
        jLabel4.setToolTipText("Canridad maxima de operaciones que puede realizar el metodo");

        jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/Icons16/kodo.png"))); // NOI18N
        jLabel5.setText("Valor Inicial 2");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(FieldIteraciones, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(FieldTol, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(FieldInicial, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 123, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(FieldInicial2, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel5))
                    .addComponent(jLabel3)
                    .addComponent(jLabel4))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(FieldInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addComponent(FieldInicial2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(FieldTol, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(FieldIteraciones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout PanelEntradaLayout = new javax.swing.GroupLayout(PanelEntrada);
        PanelEntrada.setLayout(PanelEntradaLayout);
        PanelEntradaLayout.setHorizontalGroup(
            PanelEntradaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelEntradaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PanelEntradaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(LabelInStatus, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 81, Short.MAX_VALUE)
                .addComponent(BotonEjecutar)
                .addContainerGap())
        );
        PanelEntradaLayout.setVerticalGroup(
            PanelEntradaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelEntradaLayout.createSequentialGroup()
                .addGroup(PanelEntradaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(BotonEjecutar)
                    .addGroup(PanelEntradaLayout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(LabelInStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 13, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(4, 4, 4))
        );

        jLabel1.setText("Metodo de la Secante");

        PanelSalida.setBorder(javax.swing.BorderFactory.createTitledBorder("Salida"));

        javax.swing.GroupLayout PanelSalidaLayout = new javax.swing.GroupLayout(PanelSalida);
        PanelSalida.setLayout(PanelSalidaLayout);
        PanelSalidaLayout.setHorizontalGroup(
            PanelSalidaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelSalidaLayout.createSequentialGroup()
                .addGroup(PanelSalidaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(LabelSalida)
                    .addGroup(PanelSalidaLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(LabelSalida2)))
                .addContainerGap(594, Short.MAX_VALUE))
        );
        PanelSalidaLayout.setVerticalGroup(
            PanelSalidaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelSalidaLayout.createSequentialGroup()
                .addComponent(LabelSalida)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 32, Short.MAX_VALUE)
                .addComponent(LabelSalida2)
                .addContainerGap())
        );

        PanelEstado.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        LabelF.setText("f(x) = ");

        javax.swing.GroupLayout PanelEstadoLayout = new javax.swing.GroupLayout(PanelEstado);
        PanelEstado.setLayout(PanelEstadoLayout);
        PanelEstadoLayout.setHorizontalGroup(
            PanelEstadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelEstadoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PanelEstadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PanelEstadoLayout.createSequentialGroup()
                        .addComponent(LabelF)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(LabelFText))
                    .addGroup(PanelEstadoLayout.createSequentialGroup()
                        .addGap(40, 40, 40)
                        .addComponent(LabelFPrimaText)))
                .addContainerGap(517, Short.MAX_VALUE))
        );
        PanelEstadoLayout.setVerticalGroup(
            PanelEstadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelEstadoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PanelEstadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(LabelF)
                    .addComponent(LabelFText))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(LabelFPrimaText)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/help.png"))); // NOI18N
        jButton1.setToolTipText("Ayuda");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(PanelEntrada, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(10, 10, 10)
                                .addComponent(PanelEstado, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(SPanelProceso, javax.swing.GroupLayout.DEFAULT_SIZE, 620, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(PanelSalida, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(PanelEstado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(PanelEntrada, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(SPanelProceso, javax.swing.GroupLayout.DEFAULT_SIZE, 257, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(PanelSalida, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
    }// </editor-fold>//GEN-END:initComponents

    /**
     * Metodo que reconstruye la tabla luego de cada ejecucion, este metodo es el
     * <br> de que la tabla muestre sus datos tal cual son
     * @param Iters
     * @param Xn
     * @param Yn
     * @param Errors
     */
    private void reBuildSecanteTableModel(ArrayList<Integer> Iters,
            ArrayList<Double> Xn,
            ArrayList<Double> Yn,
            ArrayList<Double> Errors) {
        int n = Xn.size();
        Object[][] data = new Object[n][4];
        for (int i = 0; i < n; i++) {
            data[i][0] = Iters.get(i);
            data[i][1] = Xn.get(i);
            data[i][2] = Yn.get(i);
            data[i][3] = Errors.get(i);
        }

        //Btm.setData(data);
        //Btm.fireTableDataChanged();

        DefaultTableModel tm = new DefaultTableModel(data, names);
        TableSecante.setModel(tm);
        tm.fireTableDataChanged();





    }

    private void BotonEjecutarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonEjecutarActionPerformed
        int Iter = 0;
        int resultStatus = 0;
        double x0 = 0;
        double tol = 0;
        double x1;

        //Validaciones de campos de texto
        if (!(FieldInicial.getText().equals("")) || FieldInicial.getText() != null) { //Verificar que no haya valores nulos en el campo Valor Inicial
            if (!(FieldInicial2.getText().equals("")) || FieldInicial.getText() != null) { //Verificar que no haya valores nulos en el campo Valor Inicial 2
                if (!(FieldIteraciones.getText().equals("")) || FieldIteraciones.getText() != null) { //Verificar que no haya valores nulos en el campo Iteraciones
                    if (!(FieldTol.getText().equals("")) || FieldTol.getText() != null) { //Verificar que no haya valores nulos en el campo Tolerancia
                        // <editor-fold defaultstate="collapsed" desc="Parsear los valores desde los TextFields">
                        try {
                            x0 = Double.parseDouble(FieldInicial.getText()); //Tratar de obtener un numero del campo valor inicial
                        } catch (NumberFormatException e) {
                            LabelInStatus.setText("Error obteniendo el numero desde el campo Valor Inicial");
                            return;
                        }
                        ///---------
                        try {
                            x1 = Double.parseDouble(FieldInicial2.getText()); //Tratar de obtener el segundo valor inicial
                        } catch (NumberFormatException e) {
                            LabelInStatus.setText("Error obteniendo el valor del campo Valor Inicial 2");
                            return;
                        }
                        ///--------
                        try {
                            Iter = Integer.parseInt(FieldIteraciones.getText()); //Tratar de obtener un numero del campo Iteraciones
                        } catch (NumberFormatException e) {
                            LabelInStatus.setText("Error obteniendo el valor desde el campo Iteraciones");
                            return;
                        }
                        ///--------
                        try {
                            tol = Double.parseDouble(FieldTol.getText()); //Tratar de obtener la tolerancia desde el campo tolerancia
                        } catch (NumberFormatException e) {
                            LabelInStatus.setText("Error obteniendo el campo tolerancia");
                            return;
                        }
                        ///--------
                        // </editor-fold>

                        //Obtenidos y parseados todos los valores, a trabajar
                        //Agregar la funcion f al parser
                        ManejadorFuncion.getInstance().addFuncion("f", "x", f);
                        //Solucionar el metodo
                        Secante.solucionar(x0, x1, tol, Iter);
                        //Llenar las tablas
                        reBuildSecanteTableModel(
                                Secante.Iters,
                                Secante.Xn,
                                Secante.Yn,
                                Secante.Errors);
                        //Verificar los resultados. e imprimir
                        resultStatus = Secante.getLatestStatus();
                        // <editor-fold defaultstate="collapsed" desc="Metodos para obtener y mostrar el resultado de la ultima ejecucion">

                        switch (resultStatus) {
                            case (NuMethodConstants.IS_ROOT): {
                                LabelSalida.setText("Se logro un resultado sin errores");
                                LabelSalida.setForeground(Color.GREEN);
                                LabelSalida.setIcon(okIcon);
                                LabelSalida2.setText("El resultado es: " + Secante.Xn.get(Secante.Xn.size() - 1));

                                break;
                            }
                            case (NuMethodConstants.IS_ROOT_PLUS_ERROR): {
                                LabelSalida.setText("Se logro un resultado con error");
                                LabelSalida.setForeground(Color.ORANGE);
                                LabelSalida.setIcon(halfSuccessIcon);
                                LabelSalida2.setText(
                                        "El resultado es: " + Secante.Xn.get(Secante.Xn.size() - 1) + " + un error de: " + Secante.Errors.get(Secante.Errors.size() - 1));
                                break;
                            }
                            case (NuMethodConstants.IS_ERROR): {
                                LabelSalida.setText("No fue posible encontrar un resultado con las iteraciones pedidas. devolviendo los ultimos status");
                                LabelSalida.setForeground(Color.red);
                                LabelSalida.setIcon(errorIcon);
                                LabelSalida2.setText(
                                        "Ultimo valor obtenido: " + Secante.Xn.get(Secante.Xn.size() - 1) + " + un error de: " + Secante.Errors.get(Secante.Errors.size() - 1) + " con un total de: " + Secante.Iters.get(Secante.Iters.size() - 2) + " Iteraciones");
                                break;
                            }
                            case (NuMethodConstants.IS_DIVISION_BY_ZERO): {
                                LabelSalida.setText("El Metodo encontro un error durante su ejecucion");
                                LabelSalida.setForeground(Color.red);
                                LabelSalida.setIcon(errorIcon);
                                LabelSalida2.setText("Una division por zero aparecio durante la ejecucion del metodo en la iteracion #" + Secante.Yn.get(Secante.Yn.size() - 1));
                                break;
                            }
                        }// </editor-fold>

                        //Se obtuvieron los datos, ahora podemos vaciar los arreglos temporales
                        Secante.flushTempArrays();

                        //Fin ejecucion. Dificil, no??
                    } else {
                        LabelInStatus.setText("Por favor colocar un valor en el campo Tolerancia");
                    }
                } else {
                    LabelInStatus.setText("Por favor colocar un valor en el campo Iteraciones");
                }
            } else {
                LabelInStatus.setText("Por favor colocar un valor en el campo del segundo valor inicial");
            }
        }//Fin Primer campo
        else {
            LabelInStatus.setText("Por favor colocar un valor en el campo del primer valor inicial");
        }



        //plantilla para las validaciones de entrada
//        if (!(FieldInicial.getText().equals(""))
//                || FieldInicial.getText() != null) {
//
//        }//Fin Primer campo
//        else {
//            LabelInStatus.setText("Por favor colocar un valor en el campo valor inicial");
//        }
    }//GEN-LAST:event_BotonEjecutarActionPerformed

    private void FieldInicialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FieldInicialActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_FieldInicialActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
            NuMethodApp.helpLauncher("Secante.html");
    }//GEN-LAST:event_jButton1ActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BotonEjecutar;
    private javax.swing.JTextField FieldInicial;
    private javax.swing.JTextField FieldInicial2;
    private javax.swing.JTextField FieldIteraciones;
    private javax.swing.JTextField FieldTol;
    private javax.swing.JLabel LabelF;
    private javax.swing.JLabel LabelFPrimaText;
    private javax.swing.JLabel LabelFText;
    private javax.swing.JLabel LabelInStatus;
    private javax.swing.JLabel LabelSalida;
    private javax.swing.JLabel LabelSalida2;
    private javax.swing.JPanel PanelEntrada;
    private javax.swing.JPanel PanelEstado;
    private javax.swing.JPanel PanelSalida;
    private javax.swing.JScrollPane SPanelProceso;
    public org.jdesktop.swingx.JXTable TableSecante;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JPanel jPanel2;
    // End of variables declaration//GEN-END:variables
}
